<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@ page import="java.io.*,java.text.*, javax.servlet.*" %>
<!DOCTYPE html>
<html>
<head>
<title>凭证汇总</title>
</head>
<body>	
	<%
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	String date= format.format(new Date());
	%>
	<div class="easyui-layout" data-options="fit : true,border : false" id="div1">
		<div data-options="region:'north',title:'',border:false" style="height: 100px; overflow: hidden;" >
			<form id="searchForm1">
				<table class="form_view_border" bordercolordark="#FFFFFF" bordercolorlight="#45b97c" border="px" cellpadding="0" cellspacing="0" style="">
					<tr>
						<th class="panel-header"><nobr>核算单位</nobr></th>
						<td>
							<select name="HSDW" style="width: 200px;height: 27px;" class="easyui-text">
							<option value="">请选择</option>
								 <c:forEach items="${requestScope.list}" var="b">
								 
								<option value="${b.HSDW}">${b.HSDW}</option>
								
								</c:forEach> 
							</select>
						</td>
						<th class="panel-header"><nobr>帐套编号</nobr></th>
						<td>
							<select name="ZTBH" style="width: 200px;height: 27px;" class="easyui-text">
							<option value="">请选择</option>
							 <c:forEach items="${requestScope.list}" var="b">
								<option value="${b.ZTDM}">${b.ZTDM}</option>
								</c:forEach>
							</select>
						</td>
						<th class="panel-header"><nobr>汇总日期</nobr></th>
						<td>
							<input name="ZDRQ_EQ_DATE" value="<%=date%>"  data-options="value:new Date().Format('yyyy-MM-dd')" style="width: 200px;height: 27px;"  class="form_view_input combo easyui-datebox" />
						</td>
						<th class="panel-header"><nobr>凭证类别</nobr></th>
						<td>
							<select name="PZLB" style="width: 200px;height: 27px;" class="easyui-text">
							<option value="">请选择</option>
							<c:forEach items="${requestScope.list}" var="b">
								<option value="${b.PZLB}">${b.PZLB}</option>
							</c:forEach>
							</select>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div  data-options="region:'center',border:false">
			<table id="pzhz"></table>
		</div>
	</div>
	<div class="easyui-layout" data-options="fit : true,border : false" id="div2">
		<div data-options="region:'north',title:'',border:false" style="height: 100px; overflow: hidden;" >
			<form id="searchForm">
				<table class="form_view_border" bordercolordark="#FFFFFF" bordercolorlight="#45b97c" border="px" cellpadding="0" cellspacing="0" style="">
					<tr>
						<th class="panel-header"><nobr>核算单位</nobr></th>
						<td>
							<select style="width: 200px;height: 27px;" class="easyui-text">
								<option>请选择</option>
							</select>
						</td>
						<th class="panel-header"><nobr>帐套名称</nobr></th>
						<td>
							<select style="width: 200px;height: 27px;" class="easyui-text">
								<option >公积金帐套</option>
							</select>
						</td>
						<th class="panel-header"><nobr>汇总日期</nobr></th>
						<td>
							<input name="ZDRQ_EQ_DATE" style="width: 200px;height: 27px;"  class="form_view_input combo easyui-datebox" />
						</td>
						<th class="panel-header"><nobr>凭证类别</nobr></th>
						<td>
							<select style="width: 200px;height: 27px;" class="easyui-text">
								<option>请选择</option>
							</select>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div  data-options="region:'center',border:false">
			<table id="yihz"></table>
		</div>
	</div>
<div id="c1">
	<div id="hztoolbar" style="display: none;">
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="daihuizong();">待汇总记账凭证</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="yihuizong();">已汇总记账凭证</a>
	
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="searchFun();">查询</a>
		    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_delete',plain:true" onclick="cleanFun();">重置</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="huizong();">汇总</a>
			
	
	</div>
	 <div id="hzmenu" class="easyui-menu" style="width: 120px; display: none;">
			<div onclick="addFun();" data-options="iconCls:'pencil_add'">增加</div>
			<div onclick="deleteFun();" data-options="iconCls:'pencil_delete'">删除</div>
			<div onclick="editFun();" data-options="iconCls:'pencil'">编辑</div>
	</div>  
</div>
<div id="c2">
	<div id="yitoolbar" style="display: none;">
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="daihuizong();">待汇总记账凭证</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="yihuizong();">已汇总记账凭证</a>
			
	
	</div>
	 <div id="yimenu" class="easyui-menu" style="width: 120px; display: none;">
			<div onclick="addFun();" data-options="iconCls:'pencil_add'">增加</div>
			<div onclick="deleteFun();" data-options="iconCls:'pencil_delete'">删除</div>
			<div onclick="editFun();" data-options="iconCls:'pencil'">编辑</div>
	</div>  <script type="text/javascript">
		var dataGrid;
		$(function() {
			$("#div2").hide();
			$("#c2").hide();
			dataGrid = $('#pzhz').datagrid({
				url :'${pageContext.request.contextPath}/business/accounting/gB_JZPZXX/dataGrid.shtml',
				fit : true,
				border : false,
				pagination : true,
				pageSize : 20,
				pageList : [ 10, 20, 30, 40, 50 ],
				columns : [ [ {
						field : 'ZHAIYAO',
						title : '摘要',
						width : 83,
						align : 'center',
						sortable : true
					}, {
						field : 'JFFSE',
						title : '借方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'DFFSE',
						title : '贷方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'FJDJS',
						title : '附件单据数',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JZRQ',
						title : '记账日期',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'ZD',
						title : '制单',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JZ',
						title : '记账',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'FH',
						title : '复核员',
						width : 80,
						align : 'center',
						sortable : true
					}
					, {
						field : 'PZZTBS',
						title : '凭证状态标记',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'BIAOJI',
						title : '标记',
						width : 70,
						align : 'center',
						sortable : true,
						formatter : function(value, rowData, rowIndex) {
							if(value==1){
								return '待汇总';
							}else if(value==2){
								return '已汇总';
							}else{
								return value;
							}	
						}
					}
					, {
						field : 'HZPZH',
						title : '汇总凭证号',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'PZLB',
						title : '凭证类别',
						width : 100,
						align : 'center',
						sortable : true
					},{
						field : 'ZJYWLX',
						title : '资金业务类型',
						width : 100,
						align : 'center',
						sortable : true
					},{
						field : 'ID',
						title : '操作',
						align : 'center',
						width : 100,
						formatter : function(value, row, index) {
							var str = '';
								str += $.formatString('<a onclick="editFun(\'{0}\');">查看</a>', row.ID);
							str += '&nbsp;';
								str += $.formatString('<a onclick="deleteFun(\'{0}\');">上传</a>', row.ID);
							str += '&nbsp;';
							return str;
						}
					}
					
					]],
				toolbar : '#hztoolbar',
				onLoadSuccess : function() {
					$('#searchForm table').show();
					parent.$.messager.progress('close');
					$(this).datagrid('tooltip');
				},
				
			});	
		});
	
		function searchFun() {
			var opts = dataGrid.datagrid("options");
		    opts.url = "${pageContext.request.contextPath}/business/accounting/gB_JZPZXX/dataGrid.shtml";
			dataGrid.datagrid('load',$.serializeObject($('#searchForm1')));
		}
		
		function cleanFun() {
			$('#searchForm input').val('');
			dataGrid.datagrid('load', {});
		}
		function huizong() {
			var opts = dataGrid.datagrid("options");
		    opts.url = "${pageContext.request.contextPath}/business/accounting/pZHZ/add.shtml";
			dataGrid.datagrid('load',$.serializeObject($('#searchForm1')));
			$.messager.alert("提示", "已为您汇总成功", "info");
			$("#div1").hide();
			$("#c1").hide();
			$("#div2").show();
			$("#c2").show();
		}
		
	 	
 	</script>
</div>

<script type="text/javascript">
	function yihuizong() {
		var dataGrid;
		$(function() {
			$("#div1").hide();
			$("#c1").hide();
			$("#div2").show();
			$("#c2").show();
			dataGrid = $('#yihz').datagrid({
				url : '${pageContext.request.contextPath}/business/accounting/pZHZ/dataGrid.shtml',
				fit : true,
				border : false,
				pagination : true,
				
				pageSize : 20,
				pageList : [ 10, 20, 30, 40, 50 ],
				
				columns : [ [ {
					field : 'ID',
					title : '操作',
					align : 'center',
					width : 100,
					formatter : function(value, rowData, rowIndex) {	
						var str = '';
						str += $.formatString('<a href="#" onclick="qxhz(\'{0}\');">取消汇总</a>', rowData.HZPZH);
						 return str;
					}
					
				},{
						field : 'ZHAIYAO',
						title : '摘要',
						width : 83,
						align : 'center',
						sortable : true
					}, {
						field : 'JFFSE',
						title : '借方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'DFFSE',
						title : '贷方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'FJDJS',
						title : '附件单据数',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JZRQ',
						title : '记账日期',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'ZHIDAN',
						title : '制单',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JIZHANG',
						title : '记账',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'FHY',
						title : '复核员',
						width : 80,
						align : 'center',
						sortable : true
					}
					, {
						field : 'PZZTBJ',
						title : '凭证状态标记',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'BIAOJI',
						title : '标记',
						width : 70,
						align : 'center',
						sortable : true,
						formatter : function(value, rowData, rowIndex) {
							if(value==2){
								return '待汇总';
							}else if(value==1){
								return '已汇总';
							}else{
								return value;
							}	
						}
					}
					, {
						field : 'HZPZH',
						title : '汇总凭证号',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'PZLB',
						title : '凭证类别',
						width : 100,
						align : 'center',
						sortable : true
					},{
						field : 'ZJYWLX',
						title : '资金业务类型',
						width : 100,
						align : 'center',
						sortable : true
					},{
						
						title : '操作',
						align : 'center',
						width : 100,
						formatter : function(value, row, index) {
							var str = '';
								str += $.formatString('<a onclick="editFun(\'{0}\');">查看</a>', row.ID);
							str += '&nbsp;';
								str += $.formatString('<a onclick="deleteFun(\'{0}\');">上传</a>', row.ID);
							str += '&nbsp;';
							return str;
						}
					}
					
					]],
				toolbar : '#yitoolbar',
				onLoadSuccess : function() {
					$('#searchForm table').show();
					parent.$.messager.progress('close');
					$(this).datagrid('tooltip');
				},
				onRowContextMenu : function(e, rowIndex, rowData) {
					e.preventDefault();
					$(this).datagrid('unselectAll');
					$(this).datagrid('selectRow', rowIndex);
					$('#yimenu').menu('show', {
						left : e.pageX,
						top : e.pageY
					});
				}
			});
		});
	}
		function qxhz(ID){  
			$.messager.alert("提示", "您确认要取消汇总吗？", "info"); 
			var opts = dataGrid.datagrid("options");
		    opts.url = "${pageContext.request.contextPath}/business/accounting/pZHZ/delete.shtml?id="+ID;
			dataGrid.datagrid('load',$.serializeObject($('#searchForm')));
		}  
	function daihuizong() {
		var dataGrid;
		$(function() {
			$("#div2").hide();
			$("#c2").hide();
			$("#div1").show();
			$("#c1").show();
			dataGrid = $('#pzhz').datagrid({
				url : '${pageContext.request.contextPath}/business/accounting/gB_JZPZXX/dataGrid.shtml',
				fit : true,
				border : false,
				pagination : true,
				
				pageSize : 20,
				pageList : [ 10, 20, 30, 40, 50 ],
				
				columns : [ [{
						field : 'ZHAIYAO',
						title : '摘要',
						width : 83,
						align : 'center',
						sortable : true
					}, {
						field : 'JFFSE',
						title : '借方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'DFFSE',
						title : '贷方发生额',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'FJDJS',
						title : '附件单据数',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JZRQ',
						title : '记账日期',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'ZD',
						title : '制单',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'JZ',
						title : '记账',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'FH',
						title : '复核员',
						width : 80,
						align : 'center',
						sortable : true
					}
					, {
						field : 'PZZTBS',
						title : '凭证状态标记',
						width : 100,
						align : 'center',
						sortable : true
					}
					, {
						field : 'BIAOJI',
						title : '标记',
						width : 70,
						align : 'center',
						sortable : true,
						formatter : function(value, rowData, rowIndex) {
							if(value==1){
								return '待汇总';
							}else if(value==2){
								return '已汇总';
							}else{
								return value;
							}	
						}
					}
					, {
						field : 'HZPZH',
						title : '汇总凭证号',
						width : 100,
						align : 'center',
						sortable : true
					}, {
						field : 'PZLB',
						title : '凭证类别',
						width : 100,
						align : 'center',
						sortable : true
					},{
						field : 'ZJYWLX',
						title : '资金业务类型',
						width : 100,
						align : 'center',
						sortable : true
					},{
						field : 'BIAOJI',
						title : '标记',
						width : 70,
						align : 'center',
						sortable : true,
						formatter : function(value, rowData, rowIndex) {
							if(value==1){
								return '待汇总';
							}else if(value==2){
								return '已汇总';
							}else{
								return value;
							}	
						}
					}
					
					]],
				
			});
			
			
		});
		
	}
	
</script>
<script type="text/javascript">
$(function(){
	var opts = dataGrid.datagrid("options");
    opts.url = "${pageContext.request.contextPath}/business/accounting/gB_JZPZXX/dataGrid.shtml";
	dataGrid.datagrid('load',$.serializeObject($('#searchForm1')));
});
/* 下面这个方法是前台判断去掉重复下拉框回显 */
$("select").each(function(i,n){
    var options = "";
    $(n).find("option").each(function(j,m){
        if(options.indexOf($(m)[0].outerHTML) == -1)
        {
            options += $(m)[0].outerHTML;
        }
    });
    $(n).html(options);
}); 
</script>
</body>
</html>